<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Gq\VideoMonitoring\Request;

use Hyperf\Validation\Request\FormRequest;

/**
 * 摄像头管理验证数据类
 */
class GqVideoCameraRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            //摄像头名称 验证
            'name' => 'required|max:100',
            'short_name' => 'required|max:50',
            'device_code' => 'required|max:50',
            'device_serial' => 'required|max:100',
            'manufacturer' => 'required|max:100',
            'ip_address' => 'required|ip',
            'port' => 'required|integer|min:1|max:65535',
            'username' => 'required|max:50',
            'password' => 'required',
            'play_url' => 'required',
            'location' => 'required',
            'longitude' => 'nullable|numeric|between:-180,180',
            'latitude' => 'nullable|numeric|between:-90,90',
            'status' => 'required|in:0,1',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键ID',
            'name' => '摄像头名称',
            'short_name' => '摄像头简称',
            'device_code' => '设备编号',
            'device_serial' => '设备序列号',
            'manufacturer' => '厂家',
            'ip_address' => 'IP地址',
            'port' => '端口号',
            'username' => '账户',
            'password' => '密码',
            'play_url' => '播放地址',
            'location' => '位置',
            'longitude' => '经度坐标',
            'latitude' => '纬度坐标',
            'status' => '状态',
        ];
    }

public function messages(): array
{
    return [
        'name.required' => '摄像头名称不能为空',
        'name.max' => '摄像头名称不能超过100个字符',
        'short_name.required' => '摄像头简称不能为空',
        'short_name.max' => '摄像头简称不能超过50个字符',
        'device_code.required' => '设备编号不能为空',
        'device_code.max' => '设备编号不能超过50个字符',
        'device_serial.required' => '设备序列号不能为空',
        'device_serial.max' => '设备序列号不能超过100个字符',
        'manufacturer.required' => '厂家不能为空',
        'manufacturer.max' => '厂家不能超过100个字符',
        'ip_address.required' => 'IP地址不能为空',
        'ip_address.ip' => 'IP地址格式不正确',
        'port.required' => '端口号不能为空',
        'port.integer' => '端口号必须是整数',
        'port.min' => '端口号不能小于1',
        'port.max' => '端口号不能大于65535',
        'username.required' => '账户不能为空',
        'password.required' => '密码不能为空',
        'play_url.required' => '播放地址不能为空',
        'location.required' => '位置不能为空',
        'longitude.numeric' => '经度坐标必须是数字',
        'longitude.between' => '经度坐标必须在-180到180之间',
        'latitude.numeric' => '纬度坐标必须是数字',
        'latitude.between' => '纬度坐标必须在-90到90之间',
        'status.required' => '状态不能为空',
        'status.in' => '状态只能是0（离线）或1（在线）',
    ];
}
}